// 封装与文章相关的操作
import instance from '@/utils/request'

export const reqGetArticles = (channelId, timestamp) => {
  console.log(123)
  return instance({
    method: 'get',
    url: 'v1_1/articles',
    params: {
      with_top: 1, // 包含置顶文章
      channel_id: channelId, // 当前频道编号
      timestamp // 时间戳
    }
  })
}
// 不感兴趣接口
export const reqDisLikeArticle = (target) => {
  return instance({
    method: 'post',
    url: 'v1_0/article/dislikes',
    data: {
      target // 不喜欢文章id
    }
  })
}
// 举报文字接口
export const reqReportArticle = (target, type) => {
  return instance({
    method: 'POST',
    url: 'v1_0/article/reports',
    // post请求携带参数使用data
    data: {
      target, // 举报文章的id
      type // 举报类型： 0-其他问题，1-标题夸张，2-低俗色情，3-错别字多，4-旧闻重复，5-广告软文，6-内容不实，7-涉嫌违法犯罪，8-侵权'
    }
  })
}
// 展示文章详情
export const reqGetArticleDetail = (id) => {
  return instance({
    method: 'get',
    url: 'v1_0/articles/' + id
  })
}
// 获取文章评论
export const reqGetComments = (articleId, offset) => {
  return instance({
    method: 'get',
    url: 'v1_0/comments',
    params: {
      type: 'a',
      source: articleId,
      offset,
      limit: 10
    }
  })
}
// 发布评论
export const reqAddComment = (target, content) => {
  return instance({
    method: 'post',
    url: 'v1_0/comments',
    data: {
      target,
      content
    }
  })
}
// 获取评论回复
export const reqGetCommentsReplys = (articleId, offset) => {
  return instance({
    method: 'get',
    url: 'v1_0/comments',
    params: {
      type: 'c',
      source: articleId,
      offset
    }
  })
}
